package org.enwey.icarenew.Component;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.enwey.icarenew.Model.Topic;
import org.enwey.icarenew.R;


/**
 * Created by enwey on 2014/11/20.
 */
public class TopicItem extends LinearLayout {
    private TextView mTopicTitle;
    private TextView mTopicDescribe;
    private TextView mTopicNick;
    private TextView mSupportNum;
    private TextView mCommentNum;
    private TextView mTopicDate;
    private ImageView mUserImg;

    public TopicItem(Context context) {
        super(context);
        initView();
    }
    public TopicItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    private void initView() {
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.topic_item, this);
        findView(view);
    }

    private void findView(View view) {
        mTopicTitle = (TextView) view.findViewById(R.id.topic_item_title);
        mTopicDate = (TextView) view.findViewById(R.id.topic_item_date);
        mUserImg = (ImageView) view.findViewById(R.id.topic_item_user_img);
        mTopicNick = (TextView) view.findViewById(R.id.topic_item_nick);
        mSupportNum = (TextView) view.findViewById(R.id.topic_item_support);
        mCommentNum = (TextView) view.findViewById(R.id.topic_item_comment);
    }

    public void setTopicData(Topic topic) {
//        Log.v("TopicItem", "================="+topic.nick);
        mTopicTitle.setText(topic.title+ "");
        mTopicDate.setText(topic.date+ "");
        mTopicNick.setText(topic.nick+ "");
        mSupportNum.setText(topic.support+ "");
        mCommentNum.setText(topic.comment+ "");
    }
}
